package com.ymatou.iapi.withdraw.testcase;

import java.math.BigDecimal;
import java.util.List;








import net.sf.json.JSONArray;
import net.sf.json.JSONObject;








import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;








import com.sun.org.apache.bcel.internal.generic.NEW;
import com.ymatou.iapi.withdraw.parameter.WithDrawInvoiceListQueryBean;
import com.ymatou.iapi.withdraw.parameter.applyBankWithDrawForHunterBean;
import com.ymatou.iapi.withdraw.service.WithDrawInvoiceListQueryCall;
import com.ymatou.iapi.withdraw.service.applyBankWithDrawForHunterCall;
import com.ymatou.userservice.service.UserIdMappingMobileDtoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.AccountCallServiceV2;
import com.ymttest.database.model.withdraw.Ymt_InvoiceFundFlowLogExample;
import com.ymttest.database.model.withdraw.Ymt_InvoiceOperationLogExample;
import com.ymttest.database.model.withdraw.Ymt_InvoiceSerialSeedExample;
import com.ymttest.database.model.withdraw.Ymt_WithDrawIdempotentExample;
import com.ymttest.database.model.withdraw.Ymt_WithDrawInvoice;
import com.ymttest.database.model.withdraw.Ymt_WithDrawInvoiceExample;
import com.ymttest.database.model.withdraw.Ymt_WithDrawInvoiceXloboLogExample;
import com.ymttest.database.sqlwapper.WithdrawWapper;
import com.ymttest.utils.TestDataManager;
/**
*提现记录列表--买家/买手提现记录查询
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_WithDrawInvoiceListQuery{
	private static WithDrawInvoiceListQueryBean bean;
	private static WithDrawInvoiceListQueryCall call;
	
	Ymt_WithDrawInvoiceExample ymtinvoive=new Ymt_WithDrawInvoiceExample();//提现申请信息主表
	Ymt_InvoiceSerialSeedExample ymtserialseed=new Ymt_InvoiceSerialSeedExample();//单据编号种子表
	Ymt_WithDrawInvoiceXloboLogExample ymtxlobolog=new Ymt_WithDrawInvoiceXloboLogExample();//提现到贝海的日志
	Ymt_InvoiceFundFlowLogExample ymtflowlog=new Ymt_InvoiceFundFlowLogExample();//资金流转操作日志表
	Ymt_InvoiceOperationLogExample ymtoperationlog=new Ymt_InvoiceOperationLogExample();//单据操作日志表
	Ymt_WithDrawIdempotentExample ymtidempotent=new Ymt_WithDrawIdempotentExample();//提现申请幂等键记录表
	
	WithdrawWapper WithdrawWapper=new WithdrawWapper();

	private final int sellerid=3383;
	private final String sellerName="wesper";
	
	private final int userId=4085;
	private final String userName="lunchzhao";
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("提现记录列表--买家/买手提现记录查询");
	}

	@Before
	public void caseUp() {
		bean=new WithDrawInvoiceListQueryBean();
		call=new WithDrawInvoiceListQueryCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_WithDrawInvoiceListQuery_001() {
		Logger.start(true,"正例-提现记录列表--买家/买手提现记录查询");
		try {
			bean.setUserId(sellerid);
			call.setData(bean);
			call.callService();		
			

			List<Ymt_WithDrawInvoice> invoivelist = WithdrawWapper.getWithDrawInvoiceByUserId(bean.getUserId());
			Logger.verifyEquals(call.getTotal(), invoivelist.size(), "验证申请总条数");
			
		     call.getWithDrawInvoiceList().stream().forEach(a->{
		    	 
		    	String  Id= JSONObject.fromObject(a).get("WithDrawInvoiceId").toString();
		    	
				Logger.verifyEquals(true, invoivelist.stream().filter(b->b.getWithDrawInvoiceId().equals(Id)).count()==1, "验证WithDrawInvoiceId");
				
			});
			
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_WithDrawInvoiceListQuery_002() {
		Logger.start(true,"正例-提现记录列表--买家/买手提现记录查询-买家");
		try {
			bean.setUserId(userId);
			call.setData(bean);
			call.callService();		
			

			List<Ymt_WithDrawInvoice> invoivelist = WithdrawWapper.getWithDrawInvoiceByUserId(bean.getUserId());
			Logger.verifyEquals(call.getTotal(), invoivelist.size(), "验证申请总条数");
			
		     call.getWithDrawInvoiceList().stream().forEach(a->{
		    	 
		    	String  Id= JSONObject.fromObject(a).get("WithDrawInvoiceId").toString();
		    	
				Logger.verifyEquals(true, invoivelist.stream().filter(b->b.getWithDrawInvoiceId().equals(Id)).count()==1, "验证WithDrawInvoiceId");
				
			});
			
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}